<template> </template>

<script>
//封装方法实现数字累加，要求能用这些调用方式：addHandle(1,2,3);addHandle(1,2)(3);addHandle(1)(2,3);addHandle(1)(2)(3);
export default {
    setup() {
        const addHandle = (a, b, c) => {
            if (a !== undefined) {
                if (b !== undefined) {
                    if (c !== undefined) {
                        //addHandle(1,2,3);
                        return a + b + c;
                    } else {
                        //addHandle(1,2)(3);
                        return (d) => {
                            return a + b + d;
                        };
                    }
                } else {
                    return (e, f) => {
                        if (f !== undefined) {
                            //addHandle(1)(2,3);
                            return a + e + f;
                        } else {
                            //addHandle(1)(2)(3);
                            return (g) => {
                                return a + e + g;
                            };
                        }
                    };
                }
            }
        };
        let sum1 = addHandle(1, 2, 3);
        let sum2 = addHandle(1, 2)(3);
        let sum3 = addHandle(1)(2, 3);
        let sum4 = addHandle(1)(2)(3);
        console.log({ sum1, sum2, sum3, sum4 });
    },
};
</script>

<style></style>
